/*
 * @Description: Date对象
 * @Author: rendc
 * @Date: 2021-09-02 10:25:40
 * @LastEditors: rendc
 * @LastEditTime: 2021-09-02 12:18:45
 */
// var str = "2021-09-05";
// var date = new Date(str);
// var date = new Date();
// console.log(date);
// console.log(date.getDate());
// console.log(date.getDay());
// console.log(date.getFullYear());
// console.log(date.getHours());
// console.log(date.getMinutes());
// console.log(date.getSeconds());
// console.log(date.getMilliseconds());
// console.log(date.getMonth());
// console.log(date.getTime());
// console.log(date.getYear());
// console.log(date.valueOf());
// console.log(date.toDateString());
// console.log(date.toTimeString());
// console.log(date.toISOString());
// console.log(date.toJSON());
// console.log(date.toString());
var date = new Date();
console.log(date);
// 2021-09-02 10:25:40
console.log(dateFMT(new Date()));
function dateFMT (date) {
  // var date = new Date();
  var y = date.getFullYear();
  var m = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
  var d = date.getDate().toString().padStart(2, "0");
  var hh = date.getHours().toString().padStart(2, "0");
  var mm = date.getMinutes().toString().padStart(2, "0");
  var ss = date.getSeconds().toString().padStart(2, "0");
  return y + "-" + m + "-" + d + " " + hh + ":" + mm + ":" + ss;
}
var moment = require("moment");

var date = new Date();
var result = moment(date).format("YYYY-MM-DD hh:mm:ss");
console.log(result);

var date = new Date();

console.log(date.getTime());
var thisTime = date.getTime()
var time = moment(thisTime).format("YYYY-MM-DD hh:mm:ss");
console.log(time);